import axios from 'axios';  //axios
// var urlHead = "/cYouHuiZhongXin/public/index.php/index/";   //本地访问
var urlHead="/cYouHuiZhongXin/public/index.php/index/";   //服务器访问
export default {
    getAxio(type,url,method,data){
        //type: 1 json  0 obj
        if (type == 1){
            return axios({
                url: url,
                method: method,
                data: data,
                headers: {
                    'Content-Type': 'application/json;charset=UTF-8',  //不加这段，post请求的时候数据，后台接收不到数据
                    // 'Cookie': 'PHPSESSID='+sid,
                    // 'X-Requested-With': 'XMLHttpRequest'  //若需要ajax方式的请求，可加这个header
                }
            })
                .then(res => {
                    return res.data;
                })
        }else{
            return axios({
                url: url,
                method: method,
                data: data,
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',  //不加这段，post请求的时候数据，后台接收不到数据
                    // 'Cookie': 'PHPSESSID='+sid,
                    // 'X-Requested-With': 'XMLHttpRequest'  //若需要ajax方式的请求，可加这个header
                }
            })
                .then(res => {
                    return res.data;
                })
        }

    },
    urlHead:urlHead
}